package com.yan.utils;

import com.alibaba.fastjson.JSONArray;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by yanl_ on 2018/3/13.
 */
public class DDD {

    public enum Bank {
        ICBC("0001"), YNRCC("96500"), BOC("95566"), BOCM("95599"), UNKNOWN("");


        private String bank;

        private Bank(String str) {
            this.bank = str;
        }

        private String getBank() {
            return this.bank;
        }

        private void setBank(String b) {
            this.bank = b;
        }

        //覆盖enum.toString()方法
        public String toString() {
            return bank;
        }

        /**
         * @param str
         * @return
         * @功能 : TODO 将输入值变成枚举常量值，注意该方法需要再外部调用，应定义为static
         */
        public static Bank getBank(String str) {
            System.out.println("str=" + str);
            try {
                System.out.println("valueOf(str)=" + valueOf(str));
                return valueOf(str);
            } catch (Exception e) {
                System.out.println("....");
                return UNKNOWN;
            }
        }

    }

    //实例化枚举类
    public static void testIfSwitch1(String input) {

        Bank bankList = Bank.getBank(input);
        System.out.println("53   ====bankList=" + bankList + ",bankList.hashCode=" + bankList.hashCode());

        switch (bankList) {
            case YNRCC: {
                System.out.println("YNRCC bankList=" + bankList);
                //自定义业务逻辑
            }
            ;
            break;
            case ICBC: {
                System.out.println("ICBC bankList=" + bankList);
                //自定义业务逻辑
            }
            ;
            break;
            case BOC: {
                System.out.println("BOC bankList=" + bankList);
                //自定义业务逻辑
            }
            ;
            break;
            case BOCM: {
                System.out.println("BOCM bankList=" + bankList);
                //自定义业务逻辑
            }
            ;
            break;
            default:
                System.out.println("defalut bankList=" + bankList);
                break;
        }
    }


    public static void main(String[] args) {
        testIfSwitch1("0001");
        List<String> list = new ArrayList<String>();
        String reqJson = JSONArray.toJSONString(list);
        System.out.println(
                reqJson
        );
    }
}
